package cn.liit.weixin.core.basic.jsapi;

import java.util.Date;

/**
 * 存放jsapi_ticket信息
 * jsapi_ticket是公众号的全局唯一票据，公众号调用各接口时都需使用jsapi_ticket。
 * 开发者需要进行妥善保存。jsapi_ticket的存储至少要保留512个字符空间。
 * jsapi_ticket的有效期目前为2个小时，需定时刷新，重复获取将导致上次获取的jsapi_ticket失效。
 * @author boqi.zhang
 */
public class JsapiTicket {
	private String jsapi_ticket;//获取到的凭证
	private Integer expires_in;//凭证有效时间，单位：秒
	private boolean isloaded;//用来标记凭证是否已经加载
	private Date expires_date;//到期时间
	private Integer errcode;
	private String errmsg;
	private volatile static JsapiTicket instance;//实例
	
	public String getJsapi_ticket() {
		return jsapi_ticket;
	}
	public void setJsapi_ticket(String jsapi_ticket) {
		this.jsapi_ticket = jsapi_ticket;
	}
	public Integer getExpires_in() {
		return expires_in;
	}
	public void setExpires_in(Integer expires_in) {
		this.expires_in = expires_in;
	}
	
	public boolean isIsloaded() {
		return isloaded;
	}
	public Integer getErrcode() {
		return errcode;
	}
	public void setErrcode(Integer errcode) {
		this.errcode = errcode;
	}
	public String getErrmsg() {
		return errmsg;
	}
	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}
	public void setIsloaded(boolean isloaded) {
		this.isloaded = isloaded;
	}
	private JsapiTicket() {
		super();
	}
	
	public Date getExpires_date() {
		return expires_date;
	}
	public void setExpires_date(Date expires_date) {
		this.expires_date = expires_date;
	}
	public static JsapiTicket getInstance(){
		if(instance == null){
			synchronized (JsapiTicket.class) {
				instance = new JsapiTicket();
			}
		}
		return instance;
	}
	@Override
	public String toString() {
		return "AccessToken [jsapi_ticket=" + jsapi_ticket + ", expires_in="
				+ expires_in + "]";
	}
	
}
